package util

import (
	"github.com/beherochuling/beesoft_api/app/helper/net"
	"github.com/beherochuling/beesoft_api/app/service"
	"github.com/gogf/gf/v2/net/ghttp"

	thisModel "github.com/beherochuling/beesoft_api/app/model/util/date"
	thisService "github.com/beherochuling/beesoft_api/app/service/util/datetime"
)

var Datetime datetime

type datetime struct{}

func (*datetime) Now(r *ghttp.Request) {
	var req *thisModel.NowReq
	service.Parse(r, &req)

	res, exp := thisService.Datetime.Now(r.Context(), req)
	if exp != nil {
		net.NewResponse(r).ResponseException(exp)
	}
	net.NewResponse(r).ResponseOk(res)
}
func (*datetime) Period(r *ghttp.Request) {
	var req *thisModel.PeriodReq
	service.Parse(r, &req)

	res, exp := thisService.Datetime.PeriodList(r.Context(), req)
	if exp != nil {
		net.NewResponse(r).ResponseException(exp)
	}
	net.NewResponse(r).ResponseOk(res)
}
